package wscom

import (
	"encoding/json"
	//"time"
	"dhfshop/models/im"
	"dhfshop/utils/response"
	"github.com/astaxie/beego"
)

type requestSrv struct{}

func NewRequestSrv() *requestSrv {
	return &requestSrv{}
}

/**
 * 解析请求
 */
func (r *requestSrv) ParserMsg(c *ConnectSvr, msg []byte) (err error) {
	req := im.NewRequestDao()
	if err = json.Unmarshal(msg, req); err != nil {
		beego.Debug("info: "+response.LangConf.Get("4000").MustString(), string(msg), err)
		return
	}
	//beego.Debug("Parser c.connection.User.Uid:", c.connection.User.Uid)
	switch req.Cmd {
	case "receive":
	    req.UserId = c.connection.User.Uid
		ReceiveSvr.reqDao <- req
	}
	return
}
